<template>
	<view>
		<u-navbar :background="background" :borderBottom="false">
			<view class="ft_16 fw-b">{{is_bind?'修改银行卡':'绑卡'}}</view>
		</u-navbar>
		<view class="content">
			<view class="con_1">
				<view class="display just_space alipay">
					<view class="">开户行</view>
					<u-input type="text" input-align="right" v-model="bankcard.bank_deposit" placeholder="请输入开户行"/>
				</view>
				<view class="display just_space alipay">
					<view class="">银行卡号</view>
					<u-input type="number" input-align="right" v-model="bankcard.bank_card" placeholder="请输入银行卡号"/>
				</view>
				<view class="display just_space alipay">
					<view class="">持卡人姓名</view>
					<u-input type="text" input-align="right" v-model="bankcard.username" placeholder="请输入真实姓名"/>
				</view>
				<view class="display just_space alipay">
					<view class="">银行预留手机号</view>
					<u-input type="number" input-align="right" v-model="bankcard.mobile" placeholder="请输入预留手机号" maxlength="11"/>
				</view>
				
			</view>
			<view class="confirmBtn ft_16" @click="addCard()">
				{{is_bind?'确认修改':'确认添加'}}
			</view>
			
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background:{backgroundColor: '#ffffff',},
				bankcard:{
					bank_deposit:"",
					bank_card:"",
					username:"",
					mobile:"",
				}, //银行卡信息
				is_bind:false, //是否绑卡
				// 6217568000062153158
			}
		},
		onLoad() {
			this.getInfo() //获取银行卡信息
		},
		methods: {
			getInfo(){ //获取提现信息
				this.$myRequest('user/bankcard',{})
				.then(res=>{
					console.log(res.data);
					let data=res.data.data
					if(data.bankcard){
						this.bankcard=data.bankcard
						this.is_bind=true
					}
				})
			},
			addCard(){ //确认添加
				for(let i in this.bankcard){
					if(this.bankcard[i]==""||this.bankcard[i]==undefined){
						this.$all.toast("检查信息是否填写正确")
						return
					}
				}
				if(!this.$all.changeBank(this.bankcard.mobile)) return
				console.log(this.bankcard);
				this.$myRequest('user/bankcard_operation',this.bankcard)
				.then(res=>{
					console.log(res.data);
					this.$all.toast(res.data.msg)
					if(res.data.code==1){
						setTimeout(()=>{
							uni.$emit('getInfo')
							uni.navigateBack()
						},800)
					}
				})
			},
			
		}
	}
</script>

<style lang="scss">
.content{
	padding: 15px;
	.con_1{
		.alipay{
			border-bottom: 1px solid #eeeeee;
			padding: 10px 0;
		}
	}
	.confirmBtn{
		margin: 50px 0;padding: 15px 0;background: linear-gradient(90deg, #F1A421 0%, #E4741F 100%);border-radius: 30px;text-align: center;color: #FFFFFF;
	}
	
}

</style>
